package com.tianshi.yingxue.service.impl;

import com.tianshi.dao.UserMapper;
import com.tianshi.entity.User;
import com.tianshi.yingxue.dto.UserVO;
import com.tianshi.yingxue.service.UserService;
import org.apache.ibatis.session.RowBounds;



import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class UserServiceImpl implements UserService {

    private UserMapper userMapper;
    @Override
    public UserVO queryPage(int page, int pageSize) {
        int offset=(page-1)*pageSize;

        RowBounds rowBounds=new RowBounds(offset,pageSize);
        List<User> users=userMapper.selectByRowBounds(new User(),rowBounds);

        int total=userMapper.selectCount(null);

        UserVO userVO=new UserVO();
        userVO.setRows(users);
        userVO.setTotal(total);
        userVO.setPage(page);

        return userVO;
    }



}